﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChaoBiaoSJLR.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ChaoBiaoGL.ChaoBiaoSJLR" Theme="Default"%>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxTreeList.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxTreeList" TagPrefix="dx" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>抄表数据录入</title>
    <script src="../../../../JS/jquery.js" type="text/javascript"></script>
    <script src="../../../../JS/AddEditCancel.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Search(s) {
            if (s.GetText() == "") {
                alert("用户号不能为空，请输入");
                txtYongHuH.focus();
            }
            else {
                hdCollection.Set("yhh", s.GetText());
                ASPxCallback1.PerformCallback("info");
                //树定位
                //hidden.onClick();
            }
           
        }
        var row;//当前记录数
        var rows;//总记录数

        $(function () {
            row = $('#row').val();
            rows = $('#rows').val();
        });
        //第一条
        function first() {
            //alert(row + ' ' + rows);
            row = 1;
            var str = '当前记录：1';
            lbdqjl.SetText(str);
            hdCollection.Set("ch", '0');
            ASPxCallback1.PerformCallback("first");
        }

        //上一条
        function last() {
            if (row <= 1) {
                alert("当前已是第一条");
            }
            else {
                row = parseInt(row) - 1;
                hdCollection.Set("RN", row);
                ASPxCallback1.PerformCallback("last");
            }
            var str = '当前记录：' + row;
            lbdqjl.SetText(str);
        }

        //下一条
        function next() {
            if (txtChaoBiaoZT.GetText() == '' || txtBenYueCH.GetText() == '' || txtBenYueSL.GetText() == '') {
                alert("抄表状态，本月抄码，本月水量不能为空，请先输入");
                return;
            }
            else {


                if (row >= rows) {
                    alert("当前已是最后一条");
                }
                else {
                    row = parseInt(row) + 1;
                    hdCollection.Set("RN", row);
                    ASPxCallback1.PerformCallback("next");
                }
                var str = '当前记录：' + row;
                lbdqjl.SetText(str);
                txtChaoBiaoZT.Focus();
            }
        }

        //最后一条
        function final() {
            row = rows;
            hdCollection.Set("RN", rows);
            ASPxCallback1.PerformCallback("final");
            var str = '当前记录：' + row;
            lbdqjl.SetText(str);
        }


        function save() {
            ASPxCallback1.PerformCallback("save");
        }

        function rowClick() {
            if (gvList.GetFocusedRowIndex() != -1) {
                hdCollection.Set("ID", gvList.GetRowKey(gvList.GetFocusedRowIndex()));
                ASPxCallback1.PerformCallback("setinfo");
            }
        }
        //开张水量改变
        function kzslChange() {
            if (txtBL.GetText() != '') {
                //alert(txtBL.GetText());
                var kzsl = parseInt(txtBenYueSL.GetText()) * (parseInt(txtBL.GetText()) / 1000);
                var kzsl2 = parseInt(Math.round(kzsl));
                txtKaiZhangSL.SetText(kzsl2);
            }
        }


        function chChange() {
            hdCollection.Set("ch", cbmCeHao.GetText());
            ASPxCallback1.PerformCallback("first");
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "info") {
                if (arr[2] == "0") {
                    alert("该用户号不存在");
                }
                else {
                    setText(arr);
                }
            }
            else if (type == "setinfo" || type == "first" || type == "last" || type == "next" || type == "final") {
                setText(arr);
            }
            else if (type == "save") {
                if (arr[2] == "1") {
                    alert("你输入的本月抄码格式不正确，请输入数字类型。");
                }
                else if (arr[2] == "2") {
                    alert("你输入的本月水量格式不正确，请输入数字类型。");
                }
                else if (arr[2] == "3") {
                    alert("此水表号不是该用户下的有效水表，请重新输入");
                }
                else if (arr[2] == "4") {
                    alert("抄表状态为空，请输入！");
                }
                else if (arr[2] == "t") {
                    alert("保存成功！");
                    gvList.PerformCallback();
                }
                else {
                    alert("保存失败！");
                }
            }

        }

        function setText(arr) {
            txtYongHuM.SetText(arr[2]);
            txtShuiJia.SetText(arr[3]);
            txtJingBH.SetText(arr[4]);
            txtQuShuiDD.SetText(arr[5]);
            cbmCeHao.SetText(arr[6]);
            txtShuiBiaoBH.SetText(arr[7]);
            txtShuiLiangLB.SetText(arr[8]);
            txtChaoBiaoZT.SetText(arr[9]);
            txtBenYueCH.SetText(arr[10]);
            txtBenYueSL.SetText(arr[11]);
            txtShangYueCM.SetText(arr[12]);
            txtShangYueSL.SetText(arr[13]);
            txtKaiZhangSL.SetText(arr[14]);
            txtBenYueDL.SetText(arr[15]);
            txtKaiZhangDL.SetText(arr[16]);
            OnKeyNext(txtChaoBiaoZT);
            // if (txtYongHuH.GetText() == "") {
            txtYongHuH.SetText(arr[17]);
            txtBL.SetText(arr[18]);
            // }
        }

        ///导入数据
        function Uploader_OnFileUploadComplete(args) {
            var mg = "共导入" + args.callbackData + "条";
            //if (args.isValid) {
            alert(mg);
            gvList.PerformCallback();
            //}
        }

    </script>
</head>

<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
           传输抄码
        </div>
        <input  id="row" runat="server" type="hidden" />
        <input  id="rows" runat="server" type="hidden"/>
          <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
         <div style="display:none;">
             <%--<dx:ASPxButton runat="server" ID="hidden" OnClick="hidden_Click" ClientInstanceName="hidden"></dx:ASPxButton>--%>
         </div>
        <asp:UpdatePanel runat="server" ID="updatePanel1">
            <ContentTemplate>
                <div style="height:100%">
                <table style="width: 98%; height: 100%">
                    <tr style="height:600px">
                        <td style="width: 40%" valign="top">
                            <div>
                                    <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" 
                                        ClientIDMode="AutoID" Settings-ShowVerticalScrollBar="true" Width="100%"   OnCustomCallback="gvList_CustomCallback">
                                        <Columns>
                                           <dx:GridViewDataTextColumn FieldName="S_CEHAO" Caption="册号" Width="50">
                                            </dx:GridViewDataTextColumn> 
                                            <dx:GridViewDataTextColumn FieldName="S_SHUIBIAOBH" Caption="水表号" Width="75">
                                            </dx:GridViewDataTextColumn> 
                                            <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="75">
                                            </dx:GridViewDataTextColumn> 
                                            <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="100">
                                            </dx:GridViewDataTextColumn> 
                                            <dx:GridViewDataTextColumn FieldName="I_BENYUECM" Caption="本月抄码" Width="75">
                                            </dx:GridViewDataTextColumn> 
                                            <dx:GridViewDataTextColumn FieldName="I_BENYUESL" Caption="本月水量" Width="75">
                                            </dx:GridViewDataTextColumn> 
                                        </Columns>
                                         <Settings VerticalScrollBarMode="Visible"  HorizontalScrollBarMode="Auto"   VerticalScrollableHeight="450"/>
                                        <SettingsPager   Mode="EndlessPaging" PageSize="100"  />
                                        <Settings ShowFooter="True" />
                                        <SettingsBehavior AllowFocusedRow="True" ColumnResizeMode="Control"   />
                                        <ClientSideEvents FocusedRowChanged="function(s,e){rowClick();}" />
                                         <ClientSideEvents Init="function(s,e){AdjustSize(250,gvList);}"  />
                                    </dx:ASPxGridView>
                            </div>
                            <div>
                                  <dx:ASPxLabel ID="zjl" Text="共0条" runat="server" ForeColor="Blue"></dx:ASPxLabel> 
                            </div>
                        </td>
                        <td style="width: 60%" align="center" valign="top">
                            <table style="height:400px">
                                <tr>
                                    <td align="right">传输水量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtChuanShuSL" runat="server" MaxLength="6" ClientEnabled="false" Width="60%">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">水量年月：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtShuiLiangYM" runat="server" MaxLength="6" ClientEnabled="false" Width="60%">
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td align="right">水量单位：立方米</td>
                                </tr>
                                <tr>
                                    <td align="right">用户号：</td>
                                    <td align="left" >
                                        <dx:ASPxTextBox ID="txtYongHuH" runat="server" MaxLength="7" Width="60%" ClientInstanceName="txtYongHuH">
                                            <ClientSideEvents KeyPress="function(s,e){var code=event.keyCode;if(code==13){Search(s);}}" />
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td align="right">电量单位：万千瓦时</td>
                                </tr>
                                <tr>
                                    <td align="right">用户名：</td>
                                    <td align="left" colspan="3">
                                        <dx:ASPxTextBox ID="txtYongHuM" runat="server" Width="80%"  ClientEnabled="false" ClientInstanceName="txtYongHuM">
                                        </dx:ASPxTextBox> 
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right"><span id="span1" runat="server"></span></td>
                                    <td align="left">
                                         <dx:ASPxTextBox ID="txtJingBH" runat="server" MaxLength="7" ClientEnabled="false" Width="60%" ClientInstanceName="txtJingBH">
                                        </dx:ASPxTextBox> 
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">取水地点：</td>
                                    <td align="left" colspan="3">
                                          <dx:ASPxTextBox ID="txtQuShuiDD" runat="server" Width="80%" ClientEnabled="false" ClientInstanceName="txtQuShuiDD">
                                        </dx:ASPxTextBox> 
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">册号：</td>
                                    <td align="left">
                                           <dx:ASPxComboBox ID="cbmCeHao" ClientInstanceName="cbmCeHao" runat="server" Width="80%" >
                                               <ClientSideEvents  SelectedIndexChanged="function(s,e){chChange();}"/>
                                            </dx:ASPxComboBox> 
                                    </td>
                                    <td align="right">水价：</td>
                                    <td align="left" >
                                          <dx:ASPxTextBox ID="txtShuiJia" runat="server" Width="80%" ClientEnabled="false" ClientInstanceName="txtShuiJia">
                                        </dx:ASPxTextBox> 
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">水表编号：</td>
                                    <td align="left" >
                                          <dx:ASPxTextBox ID="txtShuiBiaoBH" runat="server" Width="80%" MaxLength="9" ClientInstanceName="txtShuiBiaoBH">
                                        </dx:ASPxTextBox> 
                                    </td>
                                    <td align="right">水量类别：</td>
                                    <td align="left">
                                          <dx:ASPxTextBox ID="txtShuiLiangLB" runat="server" Width="80%" ClientEnabled="false" ClientInstanceName="txtShuiLiangLB">
                                        </dx:ASPxTextBox> 
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">抄表状态：</td>
                                    <td align="left">
                                          <dx:ASPxTextBox ID="txtChaoBiaoZT" runat="server" Width="80%" ClientInstanceName="txtChaoBiaoZT" Text="0">
                                               <ClientSideEvents  KeyPress="function(s,e){ OnKeyNext(txtBenYueCH);}"/>
                                        </dx:ASPxTextBox> 
                                    </td>
                                    <td align="left" colspan="2" style="color:blue;">0：正常，1：估计，2：换表，3：估换，4：不抄</td>
                                </tr>
                                <tr>
                                    <td align="right">本月抄码：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtBenYueCH" runat="server" Width="80%" ClientInstanceName="txtBenYueCH">
                                            <ClientSideEvents  KeyPress="function(s,e){ OnKeyNext(txtBenYueSL);}"/>
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td align="right">上月抄码：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtShangYueCM" runat="server" ClientEnabled="false" Width="80%" ClientInstanceName="txtShangYueCM">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">本月水量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtBenYueSL" runat="server" Width="80%" ClientInstanceName="txtBenYueSL">
                                            <ClientSideEvents  KeyPress="function(s,e){ OnKeyNext(btnSave);}" TextChanged="function(s,e){kzslChange();}"/>
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td align="right">上月水量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtShangYueSL" runat="server" ClientEnabled="false" Width="80%" ClientInstanceName="txtShangYueSL">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                  <tr>
                                    <td align="right">千分比：</td>
                                      <td align="left">
                                          <table>
                                              <tr>
                                                  <td>
                                                      <dx:ASPxTextBox ID="txtBL" runat="server" Width="100%" ClientInstanceName="txtBL" ClientEnabled="true">
                                                          <ClientSideEvents />
                                                      </dx:ASPxTextBox>
                                                  </td>
                                                  <td>
                                                      <span style="font-size:14px;font-weight:bold">‰</span>
                                                  </td>
                                              </tr>
                                          </table>
                                      </td>
                                       <td align="right">开帐水量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtKaiZhangSL" runat="server" Width="80%" ClientInstanceName="txtKaiZhangSL"  ClientEnabled="false">
                                            <ClientSideEvents />
                                        </dx:ASPxTextBox>
                                    </td> 
                                </tr> 
                                 <tr>
                                     <td align="right">本月电量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtBenYueDL" runat="server" Width="80%" ClientInstanceName="txtBenYueDL" ClientEnabled="true" >
                                            <ClientSideEvents />
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td align="right">开帐电量：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtKaiZhangDL" runat="server" Width="80%" ClientInstanceName="txtKaiZhangDL" ClientEnabled="false">
                                            <ClientSideEvents />
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>  
                               <tr>
                                      <td align="left">抄表日期：</td>
                                    <td align="left">
                                        <dx:ASPxTextBox ID="txtChaoBiaoDate" runat="server" Width="80%" ClientInstanceName="txtChaoBiaoDate" ClientEnabled="True">
                                            <ClientSideEvents />
                                        </dx:ASPxTextBox>
                                    </td>
                               </tr>
                            </table>
                            <br />
                            <div >
                                <table>
                                    <tr>
                                        <td style="width: 70px;">
                                            <div onclick="first();">
                                                <img src="../../../../Images/first.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="last();">
                                                <img src="../../../../Images/last.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="next();">
                                                <img src="../../../../Images/next.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="final();">
                                                <img src="../../../../Images/final.jpg" /></div>
                                        </td>
                                        <%--<td style="">
                                            <dx:ASPxButton  ID="FirstTab6" Text="第一条" OnClick="FirstTab6_Click" UseSubmitBehavior="false"></dx:ASPxButton>
                                        </td>
                                        <td>&nbsp;&nbsp;
                                            <dx:ASPxButton  ID="LastTab6" Text="上一条" OnClick="LastTab6_Click" UseSubmitBehavior="false"></dx:ASPxButton>
                                        </td>
                                        <td>&nbsp;&nbsp;
                                            <dx:ASPxButton  ID="NextTab6" Text="下一条" OnClick="NextTab6_Click" UseSubmitBehavior="false"></dx:ASPxButton>
                                        </td>
                                        <td>&nbsp;&nbsp;
                                            <dx:ASPxButton  ID="FinalTab6" Text="最后一条" OnClick="FinalTab6_Click" UseSubmitBehavior="false"></dx:ASPxButton>
                                        </td>--%>
                                    </tr>
                                </table>
                                <table>
                                    <tr>
                                        <td>
                                            <dx:ASPxLabel runat="server" ID="lbzjl" ClientInstanceName="lbzjl" ForeColor="Blue"></dx:ASPxLabel>
                                        </td>
                                        <td>&nbsp;&nbsp;&nbsp;</td>
                                        <td>
                                            <dx:ASPxLabel runat="server" ID="lbdqjl" ClientInstanceName="lbdqjl" Text="当前记录：1" ForeColor="Blue"></dx:ASPxLabel>
                                        </td>
                                    </tr>
                                </table>
                                <div style="text-align: right;">
                                    <dx:ASPxButton ID="btnSave" runat="server" Text="保存"  UseSubmitBehavior="false" ClientInstanceName="btnSave" AutoPostBack="false">
                                         <ClientSideEvents Click="function(s, e) { save();   }" />
                                    </dx:ASPxButton>
                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃"  UseSubmitBehavior="false" AutoPostBack="false">
                                        <ClientSideEvents  Click=""/>
                                    </dx:ASPxButton>

                                </div>
                            </div>

                            <div style="text-align: center;" >
                                    <table style="text-align: center;">
                                        <tr>
                                            <td style="width:120px;">
                                               
                                            </td>
                                            <td style="width:120px;"> 
                                                <dx:ASPxUploadControl ID="UpLoadFile" runat="server" ClientInstanceName="uploader"
                                                    ShowTextBox="false" Theme="Aqua" UploadMode="Standard" ShowClearFileSelectionButton="False"
                                                    ShowProgressPanel="false" NullText="" OnFileUploadComplete="UpLoadFile_FileUploadComplete"
                                                    Width="0px">
                                                    <BrowseButton Text="导入Excel"></BrowseButton>
                                                    <ClientSideEvents FileUploadComplete="function(s, e) { Uploader_OnFileUploadComplete(e); }"
                                                        TextChanged="function(s, e) { uploader.Upload();}"></ClientSideEvents>
                                                    <ValidationSettings MaxFileSize="4194304" AllowedFileExtensions=".xls,.xlsx">
                                                    </ValidationSettings>
                                                </dx:ASPxUploadControl>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                        </td>
                    </tr>
                </table>
               </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>

</html>
